<!DOCTYPE html>
<html>
    <head>
        <title> 字符串操作-分割成数组 </title>
		<meta charset="utf-8" />
    </head>
    <body>

    </body>
    <script>
        //截取前五个字符，后面内容用......代替
        var text = "这是帖子5，主要内容是：";
        var preview = text.slice(0,5);
        preview = preview + "......";
        document.write(preview);

        //str.split("分隔符")将字符串以特定的分隔符来分割，
        //得到子字符串，将字符串作为数组的数组元素，返回该数组
        var str = "?username-zhangsan&age-20&sex-male";
        str = str.slice(1);
        var arr = str.split("&");
        //console.log(arr);
        for(var i = 1;i < arr.length;i++){
            var childArr = arr[i].split("=");
            console.log(childArr[1]);//?
        }
        
        //转换大小写toUpperCase(),toLowerCase
        var str1 = "HELLO JAVASCRIPT";
        str1 = str1.toLowerCase();
        console.log(str1);
    </script>
</html>